package be.xios.projectquiz.statuspanels;

import be.xios.projectquiz.game.Game;

/// <summary>
/// Deze klasse een verzameling van de verschillende serverpanels met hun update methods
/// </summary>
/// <author>Sebastian Kubski</author>
public class UpdatePanels {

	private ServerStatusPanel serverstatuspanel;
	private JuryMasterStatusPanel  jurymasterstatuspanel;
	private PlayerStatusPanel playerstatuspanel;
	private GameStatusPanel gamestatuspanel;
	private GameLogPanel gamelogpanel;
	
	public UpdatePanels(ServerStatusPanel serverstatuspanel, JuryMasterStatusPanel  jurymasterstatuspanel, 
							PlayerStatusPanel playerstatuspanel, GameStatusPanel gamestatuspanel, GameLogPanel gamelogpanel ) {
		this.serverstatuspanel=serverstatuspanel;
		this.jurymasterstatuspanel=jurymasterstatuspanel;
		this.playerstatuspanel=playerstatuspanel;
		this.gamestatuspanel=gamestatuspanel;
		this.gamelogpanel=gamelogpanel;
	}
	
	/// <summary>
	/// Deze method update de serverstatuspanel
	/// </summary>
	/// <author>Sebastian Kubski</author>
	public void updateServerStatusPanel() {
		serverstatuspanel.repaint();
	}
	
	/// <summary>
	/// Deze method update de jury/master status panel
	/// </summary>
	/// <parameters> int who/what en boolean status</parameters>
	/// <author>Sebastian Kubski</author>
	public void updateJuryMasterStatusPanel(int who, int what, boolean status) {
		/* Who
		 * 0: jury - 1 master
		 * What
		 * 0: connected - 1 ready
		*/
		if ( who == 0 ) {
			if ( what == 0 )
				jurymasterstatuspanel.setJuryConnected(status);
			if ( what == 1 )
				jurymasterstatuspanel.setJuryReady(status);
		} else
		if ( who == 1 ) {
			if ( what == 0 )
				jurymasterstatuspanel.setMasterConnected(status);
				jurymasterstatuspanel.setMasterReady(status);
			// tbh! master voorlopig altijd connected + ready!
		}
		jurymasterstatuspanel.repaint();
	}
	
	/// <summary>
	/// Deze method update de playerstatussen 
	/// </summary>
	/// <parameters>Game game met de playerlist in</parameters>
	/// <author>Sebastian Kubski</author>
	public void updatePlayerStatusPanel(Game currentGame) {
		playerstatuspanel.setGame(currentGame);
		playerstatuspanel.repaint();
		//omdat er mensen connected zijn!
		gamestatuspanel.updateGameInfo(currentGame);
	}
	
	/// <summary>
	/// Deze method update het spelstatus panel
	/// </summary>
	/// <author>Sebastian Kubski</author>
	public void updateGameStatusPanel(Game currentGame) {
		gamestatuspanel.updateGameInfo(currentGame);
		gamestatuspanel.repaint();
	}	
	
	/// <summary>
	/// Deze methud opdate de Gamelog panel
	/// </summary>
	/// <parameters> de string die toegevoegd moet worden<parameters>
	/// <author>Sebastian Kubski</author>
	public synchronized void updateGameLogPanel(String text) {
		gamelogpanel.updateText(text);
	}
}
